#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project ：图灵学习 
@File    ：4.给进程对象绑定的任务传递参数.py
@IDE     ：PyCharm 
@Author  ：ChenLiGao
@Date    ：2024-11-05 15:26
'''
import time
import requests

import multiprocessing

def get_images(url):
    response = requests.get(url).content

    file_name = url.rsplit("/")[-1]
    with open(file_name, "wb") as f:
        f.write(response)
        time.sleep(1)
        print("下载完成....")

    return 1

url_list = [
    "https://ww2.sinaimg.cn/mw690/008Dx8Yely1hre748fydoj30u00k0q65.jpg",
    "https://ww4.sinaimg.cn/mw690/008Dx8Yely1hrniembn9pj30gf0g8tbv.jpg",
    "https://wx1.sinaimg.cn/mw690/008Dx8Yely1hrp5nr0s79j30og0ogn08.jpg",
]


# 1.创建函数入库
if __name__ == '__main__':

    # 2.迭代url列表
    for url in url_list:
        p = multiprocessing.Process(target=get_images, args=(url,))
        p.start()